package com.kymatrix.mpo.plus.bpm.server.model.form.task;

import com.kymatrix.mpo.plus.bpm.server.model.form.instance.QueryBpmProcessInstanceResp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.experimental.Accessors;

@ApiModel(value = "管理后台 - 流程任务 Response")
@Data
@Accessors(chain=true)
public class QueryBpmTaskResp {

    @ApiModelProperty(value = "任务编号", example = "1024")
    private String id;

    @ApiModelProperty(value = "任务名字", example = "zhangsan")
    private String name;

    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "结束时间")
    private LocalDateTime endTime;

    @ApiModelProperty(value = "持续时间", example = "1000")
    private Long durationInMillis;

    @ApiModelProperty(value = "任务状态", example = "2")
    private Integer status; // 参见 BpmTaskStatusEnum 枚举

    @ApiModelProperty(value = "审批理由", example = "2")
    private String reason;

    /**
     * 负责人的用户信息
     */
    private QueryBpmProcessInstanceResp.User ownerUser;
    /**
     * 审核的用户信息
     */
    private QueryBpmProcessInstanceResp.User assigneeUser;

    @ApiModelProperty(value = "任务定义的标识", example = "Activity_one")
    private String taskDefinitionKey;

    @ApiModelProperty(value = "所属流程实例编号", example = "8888")
    private String processInstanceId;
    /**
     * 所属流程实例
     */
    private ProcessInstance processInstance;

    @ApiModelProperty(value = "父任务编号", example = "1024")
    private String parentTaskId;
    @ApiModelProperty(value = "子任务列表（由加签生成）", example = "childrenTask")
    private List<QueryBpmTaskResp> children;

    @ApiModelProperty(value = "表单编号", example = "1024")
    private String formId;
    @ApiModelProperty(value = "表单名字", example = "请假表单")
    private String formName;
    @ApiModelProperty(value = "表单的配置-JSON 字符串")
    private String formConf;
    @ApiModelProperty(value = "表单项的数组")
    private List<String> formFields;
    @ApiModelProperty(value = "提交的表单值")
    private Map<String, Object> formVariables;

    @Data
@Accessors(chain=true)
    @ApiModel(value = "流程实例")
    public static class ProcessInstance {

        @ApiModelProperty(value = "流程实例编号", example = "1024")
        private String id;

        @ApiModelProperty(value = "流程实例名称", example = "zhangsan")
        private String name;

        @ApiModelProperty(value = "提交时间")
        private LocalDateTime createTime;

        @ApiModelProperty(value = "流程定义的编号", example = "2048")
        private String processDefinitionId;

        /**
         * 发起人的用户信息
         */
        private QueryBpmProcessInstanceResp.User startUser;

    }

}
